/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CustomerInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class ListAppCompanyPeoples extends AbstractAction
/*    */ {
/*    */   public ListAppCompanyPeoples(AbstractHttpServlet servlet)
/*    */   {
/* 26 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 33 */     User user = super.getLoginUser(request);
/*    */ 
/* 35 */     int id = Util.getURLIntParameter(request.getParameter("customerId"));
/* 36 */     CustomerManager manager = new CustomerManager();
/*    */ 
/* 39 */     CustomerInfo customerInfo = manager.getCustomerRightInfo(id);
/* 40 */     if (customerInfo == null) {
/* 41 */       showErrorMessage(response, "当前客户信息不存在");
/* 42 */       return;
/*    */     }
/* 44 */     if (!customerInfo.hasViewRight(user, super.getCompany(user.companyId))) {
/* 45 */       showErrorMessage(response, "您没有查看该客户的权限");
/* 46 */       return;
/*    */     }
/*    */ 
/* 49 */     List peoples = manager.getCompanyPeoples(id);
/*    */ 
/* 51 */     response.setContentType("text/html;charset=utf-8");
/* 52 */     PrintWriter out = response.getWriter();
/* 53 */     JSONObject jsonObject = new JSONObject();
/* 54 */     jsonObject.put("error", "0");
/* 55 */     jsonObject.put("peoples", peoples);
/* 56 */     out.println(jsonObject);
/* 57 */     out.flush();
/* 58 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListAppCompanyPeoples
 * JD-Core Version:    0.6.1
 */